﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NotAClue
{
    public static class ReflectionExtensionMethods
    {
        /// <summary>
        /// Gets the property value.
        /// </summary>
        /// <param name="sourceObject">The source object.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <returns>The named properties value.</returns>
        public static Object GetPropertyValue(this Object sourceObject, string propertyName)
        {
            if (sourceObject != null)
                return sourceObject.GetType()
                    .GetProperty(propertyName)
                    .GetValue(sourceObject, null);
            else
                return null;
        }
    }
}
